package com.zrj.marking.controller;

import com.zrj.marking.entity.Customer;
import com.zrj.marking.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 客户控制器
 *
 * @author zrj
 * @since 2022/10/6
 **/
@Slf4j
@RestController
@RequestMapping("/customer")
public class CustomerController {

    @GetMapping("/get")
    public Result<String> getCustomer() {
        log.info( "【客户服务】获取成功." );
        return Result.success( "查询成功", "getCustomer Success..." );
    }

    @GetMapping("/head")
    public Result<String> getCustomerByHeadParam(@RequestHeader(required = false) String auth) {
        log.info( "【客户服务】获取成功，auth：{}", auth );
        return Result.success( "查询成功", "getCustomerByHeadParam Success..." );
    }

    /**
     * 请求路径：/customer/get?code=20221007001
     *
     * @param code
     * @return
     */
    @GetMapping("/param")
    public Result<String> getByParamCode(@RequestParam(required = false) String code) {
        log.info( "【营销服务】获取成功，getByParamCode：{}", code );
        return Result.success( "查询成功", "getByParamCode Success..." );
    }

    /**
     * 请求路径：/customer/get/20221007001
     *
     * @param code
     * @return
     */
    @GetMapping("/get/{code}")
    public Result<String> getByPathCode(@PathVariable String code) {
        log.info( "【营销服务】获取成功，getByPathCode：{}", code );
        return Result.success( "查询成功", "getByPathCode success..." );
    }

    @PostMapping("/create")
    public Result<Customer> create(@RequestBody Customer customer) {
        log.info( "【客户服务】新增成功：{}.", customer );
        return Result.success( "新增成功", customer );
    }
}
